/**
 * 题目：
 * 写一个 mySetInterVal(fn, a, b),每次间隔 a,a+b,a+2b 的时间，然后写一个 myClear，停止上面的 mySetInterVal
 */

// 实现
interface interval {
  id: null | number
};
export const mySetinterval = function(fn:()=>void, time1:number, time2: number):interval  {
  let count:number = 0;
  let myinterval:interval = {
    id: null
  };
  const timer = function(){
    myinterval.id = window.setTimeout(()=>{
      fn();
      count++;
      timer();
    },
    time1 + count * time2
    )
  }
  timer();
  return myinterval;
}

export const myClear = function(interval: any) {
  clearTimeout(interval.id);
}



